package com.sskj.bibi.bean;


import com.sskj.lib.util.CoinUtil;
import com.sskj.lib.util.TimeFormatUtil;

import java.util.Date;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-09-18 10:13
 */
public class EntrustBean {


    /**
     * id : 1
     * member_id : 1
     * account : 384111
     * currency_id : 1
     * pname : EOS
     * wtprice : 100
     * cjprice : 0.0000
     * wtnum : 10.0000
     * cjnum : 0.0000
     * totalprice : 1.0000
     * fee : 0.0010
     * type : 1
     * add_time : 1525860777
     * trade_time : 0
     * status : 0
     * otype : 1
     * tpath : 0
     * l_code : EOS
     * r_code : BDD
     */

    private String orders_id;
    private String member_id;
    private String account;
    private String currency_id;
    private String pname;
    private String wtprice;
    private String cjprice;
    private String wtnum;
    private String cjnum;
    private String totalprice;
    private String fee;
    private String type;//1 买入 2 卖出
    private String add_time;
    private String trade_time;
    private String status;
    private String otype;//1 限价 2 市价
    private String tpath;
    private String l_code;
    private String r_code;

    public String getOrders_id() {
        return orders_id;
    }

    public EntrustBean setOrders_id(String orders_id) {
        this.orders_id = orders_id;
        return this;
    }

    /**
     * 是否买入
     * @return
     */
    public boolean isBuy() {
        return "1".equals(type);
    }
    /**
     * 是否市价
     * @return
     */
    public boolean isMarket() {
        return "2".equals(otype);
    }

    /**
     * 是否市价买入
     *
     * @return
     */
    public boolean isMarketBuy() {
        return "2".equals(otype) && "1".equals(type);
    }

    public String getMember_id() {
        return member_id;
    }

    public void setMember_id(String member_id) {
        this.member_id = member_id;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getCurrency_id() {
        return currency_id;
    }

    public void setCurrency_id(String currency_id) {
        this.currency_id = currency_id;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }

    public String getWtprice() {
        return CoinUtil.keepCoinPriceMax(r_code, wtprice);
    }

    public void setWtprice(String wtprice) {
        this.wtprice = wtprice;
    }

    public String getCjprice() {
        return CoinUtil.keepCoinPriceMax(r_code, cjprice);
    }

    public void setCjprice(String cjprice) {
        this.cjprice = cjprice;
    }

    public String getWtnum() {
        return CoinUtil.keepCoinNumMax(l_code, wtnum);
    }

    public void setWtnum(String wtnum) {
        this.wtnum = wtnum;
    }

    public String getCjnum() {
        return cjnum;
    }

    public void setCjnum(String cjnum) {
        this.cjnum = cjnum;
    }

    public String getTotalprice() {
        return CoinUtil.keepCoinPriceMax(r_code, totalprice);
    }

    public void setTotalprice(String totalprice) {
        this.totalprice = totalprice;
    }

    public String getFee() {
        return fee;
    }

    public void setFee(String fee) {
        this.fee = fee;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getAdd_time() {
        return TimeFormatUtil.SF_FORMAT_G.format(new Date(Long.valueOf(add_time) * 1000));
    }

    public void setAdd_time(String add_time) {
        this.add_time = add_time;
    }

    public String getTrade_time() {
        return TimeFormatUtil.SF_FORMAT_G.format(new Date(Long.valueOf(trade_time) * 1000));
    }

    public void setTrade_time(String trade_time) {
        this.trade_time = trade_time;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getOtype() {
        return otype;
    }

    public void setOtype(String otype) {
        this.otype = otype;
    }

    public String getTpath() {
        return tpath;
    }

    public void setTpath(String tpath) {
        this.tpath = tpath;
    }

    public String getL_code() {
        return l_code.toUpperCase();
    }

    public void setL_code(String l_code) {
        this.l_code = l_code;
    }

    public String getR_code() {
        return r_code.toUpperCase();
    }

    public void setR_code(String r_code) {
        this.r_code = r_code;
    }
}
